package model;

import init.DBManagement;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import model.beans.StatisticsBean;
import model.reports.ReportBean;

public class Statistics {
	public static ArrayList getReportData( ReportBean report ){
		ArrayList arrL_retVal = new ArrayList();
		Map map_cols;
		DBManagement database = new DBManagement();
	    database.executeQuery( report.getQuery() );
	    int int_totalRows = database.getNumRows();
	    int int_totalCols = database.getNumCols();
	    for( int int_rows = 0; int_rows < int_totalRows; int_rows++){
	    	map_cols = new HashMap();
	    	for( int int_cols = 0; int_cols < int_totalCols; int_cols++){
	    		String str_colName = database.getColumnName(int_cols);
	    		String str_colValue = database.getItem(int_rows, int_cols);
	    		map_cols.put(str_colName, str_colValue);
	    	}
	    	arrL_retVal.add(new StatisticsBean( map_cols ));
	    }
	    database = null;
		return arrL_retVal;
	}
}